home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / cbibcode.arc / GOTOXY.C < prev    next >
Encoding:
C/C++ Source or Header  |  1991-08-05  |  1017 b   |  44 lines

  1. /* p881.c --- bible */
  2. #include <conio.h>
  3. #define ESC '\033'
  4. static char *fieldlabel[4] =
  5.     {"Name: ", "Street: ", "City/State/ZIP: ", "Phone: "};
  6. main()
  7. {
  8.     int left = 20, top = 10, right = 60, bottom = 20,
  9.         fieldxy[4][2] = {16, 3, 16, 4, 16, 5, 16, 6},
  10.         fieldnum = 0, maxfields = 4,
  11.         numchar = 0, c, i;
  12.     window(left, top, right, bottom);
  13.     textbackground(RED);
  14.     textcolor(YELLOW);
  15.     clrscr();
  16.     gotoxy(10, 1);
  17.     cputs("C L I E N T  D A T A");
  18.     gotoxy(1, bottom - top);
  19.     cputs("<Enter> for next field, <ESC> to exit");
  20.     for(i = 0; i < maxfields; i++)
  21.     {
  22.         gotoxy(1, fieldxy[i][1]);
  23.         cputs(fieldlabel[i]);
  24.     }
  25.     gotoxy(fieldxy[fieldnum][0], fieldxy[fieldnum][1]);
  26.     while((c = getch()) != ESC)
  27.     {
  28.         if(c == '\r')
  29.         {
  30.             fieldnum = (fieldnum + 1) % maxfields;
  31.             gotoxy(fieldxy[fieldnum][0], fieldxy[fieldnum][1]);
  32.             numchar = 0;
  33.         }
  34.         numchar++;
  35.         if(numchar < (right - left - fieldxy[fieldnum][0]))
  36.         {
  37.             if(c != '\r')
  38.                 putch(c);
  39.         }
  40.         else
  41.             putch('\007');
  42.     }
  43. getch();
  44. }